<template>
	<div>
		<CardList @getRow="handleOperate"></CardList>

		<AplidDialog v-model="visible" width="65%" :rowData="rowData">
			<InstDetail v-if="visible" :rowData="rowData" :tabList="tabList" :yearList="yearList"></InstDetail>
		</AplidDialog>
	</div>
</template>

<script setup lang="ts">
import apiMod from '@/apiMod'
import CardList from './components/cardList/index.vue'
import InstDetail from './components/InstDetail/index.vue'
import AplidDialog from '@/views/instOperate/components/AplidDialog/index.vue'

let rowData: any = ref({})
let visible = ref(false)

let tabList = ref([])
const getTypeDicData = async () => {
	let res = await apiMod.getDictItemList(['SUBSIDY_TYPE'])
	tabList.value = res.data['SUBSIDY_TYPE']
}

// 获取年份
let yearList = ref([])
const getArchiveIns = () => {
	apiMod.view_ofsSubsidyProject_years().then((res) => {
		yearList.value = res.data.map((el) => {
			return { label: el + '年', value: `${el}` }
		})
	})
}

const handleOperate = (row) => {
  let orgInfo = {}
  if(row.applyJson) {
    orgInfo = JSON.parse(row.applyJson)
  }
	rowData.value = {
    ...orgInfo,
    ...row,
  }
	visible.value = true
}

onMounted(() => {
	getTypeDicData()
	getArchiveIns()
})
</script>
<style scoped lang="scss">
:deep(.el-dialog) {
	--el-dialog-border-radius: 10px;
}
:deep(.el-dialog__header) {
	padding: 0;
	margin: 0;
}
</style>
